from rest_framework.generics import ListAPIView
from rest_framework.viewsets import ModelViewSet

from goods.models import SpecificationOption, GoodsSpecification
from meiduo_admin.serializers.goods import GoodsCategorySerializer
from meiduo_admin.serializers.option import SpecOptionSerializer
from meiduo_admin.utils import PageNum


# from meiduo_admin.serializers.specs import SpecOptionSerializer
# SpecOptionSerializer()
# class SpecOptionView(ListAPIView):
#     serializer_class = SpecOptionSerializer
#     queryset = SpecificationOption.objects.all()
#     pagination_class = PageNum

class SpecSimpleView(ListAPIView):
    serializer_class = GoodsCategorySerializer
    queryset = GoodsSpecification.objects.all()

class SpecOptionView(ModelViewSet):
    serializer_class = SpecOptionSerializer
    queryset = SpecificationOption.objects.all()
    pagination_class = PageNum

class UPdateOptionView(ModelViewSet):
    serializer_class = SpecOptionSerializer
    def get_queryset(self):
        pk = self.kwargs['pk']
        return SpecificationOption.objects.filter(id=pk)
